package com.shujia.spark.mllib

import org.apache.spark.ml.linalg
import org.apache.spark.ml.linalg.Vectors

object Demo1Vector {
  def main(args: Array[String]): Unit = {
    /**
      * 稠密向量
      */
    val vector: linalg.Vector = Vectors.dense(1.0,2.3,4.5,2.4,7.8)

    println(vector)

    /**
      * 稀疏向量
      *
      * 只保存有值的位置，0位置不保存
      */
    val vector1: linalg.Vector = Vectors.sparse(10,Array(1,2,4),Array(1.2,3.4,5.6))

    println(vector1)

    println(vector1.toDense)
  }
}
